@Safurasayyed592

If statment

January 16, 2022 · C
//Program to display a number if it is negative
#include<stdio.h>
int main() {
    int number;
    
     printf("Enter an Integer:  ");
     scanf("%d", &number);
     
     //true if number is less than 0
     if (number < 0 ) {
         printf("You entered  %d.\n", number);

Do while loop

January 15, 2022 · C
#include <stdio.h>
int main() {
    /*local variable definiton */
    int a= 10;
    /*while loop execution */
    while (a < 20) {
    printf("value of a: %d\n",a);
    a++;
    if ( a > 15) {
        /*terminate the loop using break statement*/
        break;

Do while loop

January 15, 2022 · C
#include <stdio.h>
int main() {
    /* local variable definition*/
    int a=10;
    /*do loop execution*/
    do  {
    printf("value of a: %d\n",a);
    a= a + 1 ;
    }while( a < 20 );
    return 0;
}

for loop

January 15, 2022 · C
#include <stdio.h>
int main() {
    int a;
    /* for loop execution*/
    for( a = 10; a < 20; a= a + 1 ) {
    printf("value of a: %d\n",a);
    }
    return 0;
}
#include <stdio.h>

int main() {
    
    int number;
    
    printf("Please enter a number: ");
    scanf("%d",&number);
    
    if (number < 100)
    {

Switch case

January 14, 2022 · C
#include <stdio.h>

int main() {
    
    int x=2;
    
    switch(x) {
        case 2:
    printf("Two\n");
         case 3:
    printf("Three\n");

Addition of two numbers

January 14, 2022 · C
#include <stdio.h>

int main() {
    int a=5,b=4,c=9;
    printf("Enter two numbers to add\n");
    scanf("%d%d",&a,&b);
    c = a + b;
    printf("sum of entered numbers=%d\n",c);
    return 0;
}