[Legacy Content] This page contains very old information, which might not be valid anymore, they are only kept here for legacy purposes.
if you have any inquiries, feel free to contact me! Click here

Programming Applications - Full Final Exam Solutions

Created: Wednesday, 08 January 2014 Written by Ehab Eldeeb

First of all, I would like to thank Dr. Sherif Fadel once again for this non-formal certificate!

Programming Applications Final Exams

I'll solve two exams only, I don't have enough time .. Sorry!

Here are the exams

First Exam in the first pic, Second exam in the second and third pics

 

 

First Exam

 

First Question

#include <stdio.h>
#include <conio.h>
#include <string.h>

int main(){
    char student1[100], student2[100];
    printf("Enter first student's Name: ");
    gets(student1);
    printf("Enter second student's Name: ");
    gets(student2);

    if (strcmp(student1, student2) < 0){
        printf("%c", student1[0]);
        for(int i = 0; i < strlen(student1); i++){
            if(student1[i] == ' ')
                printf("%c", student1[i+1]);
        }
        for (int j = strlen(student2); j >= 0; j--)
            printf("%c", student2[j]);
    } else if (strcmp(student1, student2) > 0){
        printf("%c", student2[0]);
        for(int i = 0; i < strlen(student2); i++){
            if(student2[i] == ' ')
                printf("%c", student2[i+1]);
        }
        for (int j = strlen(student1); j >= 0; j--)
            printf("%c", student1[j]);
    } else
        printf("The two names are identical.");
    getch();
    return 0;
}

 Second Question

#include<stdio.h>
#include<conio.h>

int main (){
    int x[100][2], q = 0, id;
    for(int i = 0; i < 100; i++){
        printf("Enter ID for item %d: ", i+1);
        scanf("%d", &x[i][0]);
        printf("Enter Quantity for item %d: ", i+1);
        scanf("%d", &x[i][1]);
    }

    for(int i=0; i<100;i++){
        if(x[i][1] < 10)
            printf("%d", x[i][0]);
    }

    for(int i = 0; i < 100; i++){
        if (x[i][1] > q){
            q = x[i][1];
            id = x[i][0];
        }
    }
    printf("Max quantity %d for id %d", q, id);
    getch();
    return 0;
}

Third Question

#include <stdio.h>
#include <conio.h>

int f (int n){
    if (n == 1)
        return 1;
    else
        return 2 * f(n-1);
}

int main(){
    int x;
    x = f(10) / f(5);
    printf("%d", x);
    getch();
    return 0;
}

Fourth Question

Check this article

 

Second Exam

 

First Question

#include <stdio.h>
#include <conio.h>
#include <string.h>

int main(){
    char long_name[21], short_name[11];
    int len;
    printf("Enter String: ");
    gets(long_name);
    len = strlen(long_name);
    printf("Length of string is %d", len);
    if(len < 10)
        strcpy(short_name, long_name);
    puts(short_name);
    puts(long_name);
    getch();
    return 0;
}

Second Question

#include <stdio.h>
#include <conio.h>

int main(){
    float x[10][10];
    float max, min;
    for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++){
            printf("Enter Element [%d][%d]", i+1, j+1);
            scanf("%f", &x[i][j]);
        }
    }
    max = x[0][0];
    min = x[0][0];
    for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++){
            if(x[i][j] > max)
                max = x[i][j]