Programming for Girls (Basic to Advance) Quiz Solutions

Programming for Girls (Basic to Advance) Quiz Solutions

MCQ

No.  Question  Answer
1   What do you use to output data?  printf()
2   What do you use to comment a single line of code?   //
3   What is the correct format of printing a variable using printf() function?  printf("format_specifier", variable_name); 
4   What does this statement do? a = 5;   Initialization of variable a
5   Which operator is used to get remainder  % 
6   What is the only function all C program must contain?  main() 
7   Which of the following is not a correct variable type?  real
8   Which of the following is the correct operator to compare two variables?  == 
9   What punctuation ends most lines of C code  ; 
10   What does this expression mean? x > 100  x is greater than 100 

 

 

Problem Solution

Problem 1: Write a program that can output the followings- 1. Your Name 2. Your School Name 3. Your class. The program should output every point in new line.

Model Solution:


#include <stdio.h>

int main()
{
    printf("Mubtasim Shahriar\n");
    printf("Shaheen Academy Feni\n");
    printf("6\n");

    return 0;
}

 

Problem 2: Write a program that can input 2 integers and output the following results- 1. addition 2. subtraction 3. multiplication. The program should output every point in new line.

Model Solution:


#include <stdio.h>

int main()
{
    int a, b, sum, diff, prod;
    scanf("%d %d", &a, &b);

    sum = a+b;
    diff = a-b;
    prod = a*b;

    printf("The sum is %d\n", sum);
    printf("The difference is %d\n", diff);
    printf("The product is %d\n", prod);

    return 0;
}

Recommended Post