You are on page 1of 6

Main body of C

#include <stdio.h>

#include <conio.h>

main(){

return 0;

Summation format

#include <stdio.h>

#include <conio.h>

main(){

int a, b ;

printf("please enter the 1st number : ");

scanf("%d", & a);

printf("please enter the 2nd number : ");

scanf("%d", & b);

printf("The summation of the numbers is %d", a+b );

return 0;

Modulo

#include <stdio.h>

#include <conio.h>

main(){
int a, b ;

printf("please enter the 1st number : ");

scanf("%d", & a);

printf("please enter the 2nd number : ");

scanf("%d", & b); 1

int c = (a%b);

printf("The modulo of the numbers is %d", c );

return 0;

#include <stdio.h>

#include <conio.h>

Arithmatci Operator:

main(){

int a = 5 * 2 - 2 * 3; // 4

int b = 5 * 2 / 2 * 3; // 15

int c = 5*(2/2)*3; // 15

int d = 5+2/2*3; //

printf(" %d %d %d %d " ,a,b,c,d );

return 0;

Relational Operators:
#include <stdio.h>

#include <conio.h>

main(){

printf("%d", 4==4); // 1

printf("%d", 4!=4); // 0

printf("%d", 2<=4); // 1

printf("%d", 3>=4); // 0

return 0;

#include <stdio.h>

#include <conio.h>

main(){

int a = 2;

int b = 2;

int c = 2;

//int c = 4;

printf("%d" , (a+b+c)/3 );

return 0;

Else if

#include <stdio.h>

#include <conio.h>

main(){
// 40 er kom = fail

// 40 er beshi 60 er kom = pass

// 59 er beshi 80 er kom = first devsion

// 80 er beshi = letter

// 100 = execelent

// lessthan 0 or greater than 100 please enter valid input

int a;

scanf("%d", & a );

if(a<0 && a>100){

printf("invalid input");

else if(a>=0 && a<40 ) {

printf("fail");

else if (a>=41 && a<=59){

printf("pass");

else if (a>=60 && a<80){

printf("first division");

else if (a>=80 && a<=99) {

printf("letter");

else if (a ==100 ){

printf("excillent");

else {
printf("invalid input");

return 0;

Ternery operator

#include <stdio.h>

#include <conio.h>

main(){

printf("plrase enter the number:");

int a ;

scanf("%d", & a);

a >=18 ? printf("adult") : printf("not adult");

return 0;

Switch case

#include <stdio.h>

#include <conio.h>

main(){

int a;
printf("enter the value :");

scanf("%d" , & a );

switch(a){

case 1 : printf("one");

break;

case 2 : printf("two");

break;

case 3 : printf("three");

break;

case 4 : printf("four");

break;

case 5 : printf("five");

break;

case 6 : printf("6");

break;

default : printf ("error");

return 0;

You might also like