0% found this document useful (0 votes)
6 views8 pages

C Programming Operators and Syntax Guide

The document discusses various C programming concepts like data types, operators, control structures and provides examples of programs to find the greatest of three numbers, calculate grade and area of circle, display even numbers from 1-100. It explains the syntax of switch case, if-else, else-if ladder statements and do-while loop. Formatting specifiers like %d, %f etc for input/output are also mentioned.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views8 pages

C Programming Operators and Syntax Guide

The document discusses various C programming concepts like data types, operators, control structures and provides examples of programs to find the greatest of three numbers, calculate grade and area of circle, display even numbers from 1-100. It explains the syntax of switch case, if-else, else-if ladder statements and do-while loop. Formatting specifiers like %d, %f etc for input/output are also mentioned.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Ans 1) Classification of Operators: 1) 2) 3) 4) 5) 6) 7) 8) Arithmetic Operators Relational Operators Logical Operators Assignment Operators Increment and decrement Operators

Conditional Operators Bitwise Operators Special Operators

Ans 2) Data types: Definition: Data types are nothing but the storage representation and machine instructions to handle constants differ from machine to machine. 1) Integer 2) Float 3) Character

Ans 3) Formatting Specifiers: 1) 2) 3) 4) 5) 6) %d Integer %f Float %x Hexadecimal %c Character %o Octal %e Exponential

Ans 4) Syntax of Switch Case statement:

swith(expression) { Case value-1: Block-1; Break;

Case value-1:

Block-1; Break; | | Case value-n: Block-n; Break;

Default: Default Block; Break; }

Syntax of If-else

if(condition) { Block of statement;

} Else { Block of statement;

Ans 5) Syntax of Else-if ladder statement:

if(condition) statement 1;

elseif(condition) statement 2;

elseif(condition) statement 3;

elseif(condition) statement n;

else default statement;

Syntax of Do while loop:

Do { Body of loop; }

While(test condition):

Q 2) 1) Program for greater number between three

#include<stdio.h> #include<conio.h> main() { int a,b,c; clrscr(); printf("\n Enter any three numbers\n"); scanf("%d%d%d",&a,&b,&c); if(a>b) { if(a>c) printf("\n %d is greater",a); else printf("\n %d is greater",c); } else { if(b>c) printf("\n %d is greater",b); else

printf("\n %d is greater",c); } getch(); return 0; }

2) Program to display students grade

#include<stdio.h> #include<conio.h> main() { int marks,avg,sum,d; clrscr(); printf("\n Enter marks of student"); scanf("%d",&marks); if(marks>=75) { printf("\n Distinction"); } else if(marks>=60) { printf("\n First class"); } else if(marks>=50) { printf("\n Second Class");

} else { printf("\n Fail"); } getch(); return 0; }

3) Program to calculate area of circle

#include<stdio.h> #include<conio.h> main() { int a,r; clrscr(); printf("\n Enter radius of circle"); scanf("%d",&r); a=3.1415*r*r; printf("\n Area of circle=%d",a); getch(); return 0; }

4)Program to display even numbers from 1-100

#include<stdio.h> #include<conio.h> main() { int i; clrscr(); for(i=1;i<=100;i++) if(i%2==0) { printf("\n %d",i); } getch(); return 0; }

4)

#include<stdio.h> #include<conio.h> main() { int a,b,c; clrscr(); printf("\n Enter any three numbers\n"); scanf("%d%d%d",&a,&b,&c); if(a>b) { if(a>c)

printf("\n %d is greater",a); else printf("\n %d is greater",c); } else { if(b>c) printf("\n %d is greater",b); else printf("\n %d is greater",c); } getch(); return 0; }

You might also like