0% found this document useful (0 votes)
35 views

DO While Loop #Include Int Main (Int X X 1 Do (Printf (" %i",x) X++ ) While (X 10)

This document contains code snippets demonstrating different programming constructs in C including if/else statements, for loops, while loops, switch/case statements, and functions. It shows how to take user input, perform calculations, and output results to the console. Overall it provides examples of basic programming logic and control flow structures commonly used in C.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

DO While Loop #Include Int Main (Int X X 1 Do (Printf (" %i",x) X++ ) While (X 10)

This document contains code snippets demonstrating different programming constructs in C including if/else statements, for loops, while loops, switch/case statements, and functions. It shows how to take user input, perform calculations, and output results to the console. Overall it provides examples of basic programming logic and control flow structures commonly used in C.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

If else statement Switch case

For loop #include <stdio.h> #include <stdio.h>


#include <stdio.h> #include <conio.h> #include <conio.h>
#include <conio.h> #define p printf
#define s scanf int main()
int main() {
{ int main() int num;
int a,b; { scanf("%i",&num);
for(a=1; b<=10; a++){ int num; swutch(num)
printf("\n %i",a); p("Enter a number to check: \n");
b=a+b; s("%i",&num); case 0;
printf("Total of printf("zero");
accumulator: %i",b); if((num>=1)&&(num<=75))
} if(num>=18) case 1;
getch(); p("allow"); printf("one");
return 0; else break;
} p("dont allow"); default:
else printf("invalid input");
p("invalid input");
While loop getch();
#include <stdio.h> getch(); return 0;
#include <conio.h> return 0; }
#define p printf }
Add
int main() #include <stdio.h>
Hello world
{ #include <conio.h>
#include <stdio.h>
int sample; #define p printf
#include <conio.h>
sample=1; #define s scanf
int main()
while(sample<=786){ int main()
{
p(" %i",sample); {
clrscr();
int a,b,c;
sample++; clrscr();
printf("Hello world!");
}
getch(); p("input quiz1: \n");
getch();
return 0; s("%i",&a);
return 0;
}
}
p("input quiz2: \n");
s("%i",&b);
DO While Loop
#include <stdio.h> c=a+b;
#include <conio.h> p("Total quiz score: %i",c);
int main()
{ getch();
int x; return 0;
x=1; }
do
{
printf(" %i",x);
x++;
}while (x<=10)

getch();
return 0;
}

You might also like