Posts

Showing posts from May, 2023

STRUCTURE IN C PROGRAMMING.

  #include <stdio.h> #include <string.h> struct student {     int id ;     int marks ;     char fav_char ;     char name [ 34 ]; }; int main () {     struct student aatifa , xyz , abc ;     aatifa . id = 1 ;     xyz . id = 2 ;     abc . id = 3 ;     aatifa . marks = 445 ;     xyz . marks = 450 ;     abc . marks = 451 ;     aatifa . fav_char = 'p' ;     xyz . fav_char = 'p' ;     abc . fav_char = 'p' ;     strcpy ( aatifa . name , "aatifa is a programmer" );     printf ( "aatifa got %d marks \n " , aatifa . marks );       printf ( "aatifa's name is: %s \n " , aatifa . name );     return 0 ; } OUTPUT: aatifa got 445 marks aatifa's name is: aatifa is a programmer

TYPEDEF IN C PROGRAMMING.

  #include <stdio.h> typedef struct student {     int id ;     int marks ;     char fav_char ;     char name [ 34 ]; } std ;     int main ()     {         // struct student s1, s2;         std s1 , s2 ;         s1 . id = 34 ;         s2 . id = 89 ;           printf ( " Value of s1's id is %d \n " , s1 . id );           printf ( "Value of s2.s id is %d \n " , s2 . id );     // typedef <previous_name> <alias_name>;     // typedef unsigned long ul;     // typedef int integer;     // ul l1, l2, l3;     // integer a=4;     // printf("%d", a);     return 0 ;     } OUTPUT: Value of s1's id is 34 Value of s2.s id is 89

UNION IN C PROGRAMMING.

  #include <stdio.h> #include <string.h> union student {     int id ;     int marks ;     char fav_char ;     char name [ 34 ]; }; int main () {     union student s1 ;     s1 . id = 1 ;     s1 . marks = 45 ;     s1 . fav_char = 'u' ;     strcpy ( s1 . name , "Aatifa" );     printf ( "The id is %d \n " , s1 . id );     printf ( "The is marks %d \n " , s1 . marks );     printf ( "The fav_char is %c \n " , s1 . fav_char );     printf ( "The name is %s \n " , s1 . name );     return 0 ; } OUTPUT: The id is 1769234753 The is marks 1769234753 The fav_char is A The name is Aatifa

Static Variables in C.

  #include <stdio.h> int b = 34 ; // this is a global variable since it is declared outside the main int func1 ( int b1 ) {     static int myvar  = 98 ;     printf ( "The value of myvar is %d \n " , myvar );     myvar ++;     printf ( "The value of inside func1 is %d \n " , b );     printf ( "The address of inside func1 is %d \n " , & b );     return b1 + myvar ; } int main () {     int b1 = 344 ;       printf ( "The address of inside main is %d \n " , & b );     int val = func1 ( b );     val = func1 ( b );     val = func1 ( b );     val = func1 ( b );     val = func1 ( b );     val = func1 ( b );     int * ptr = & val ;     printf ( "The value of func1 is %d \n " , val );     return 0 ; } OUTPUT: The address of inside func1 is 4210692 The value of myvar is 102 Th...

C Language Travel Agency Manager Exercise.

  #include <stdio.h> struct driver {     char name [ 45 ];     char dlNo [ 50 ];     char route [ 47 ];     int kms ; }; int main () {     struct driver d1 , d2 , d3 ;     printf ( "Enter the details of drivers no.1 \n " );     printf ( "Enter the name of first drivers \n " );     scanf ( " %s " , & d1 . name );     printf ( "Enter the dlNo of first drivers \n " );     scanf ( " %s " , & d1 . dlNo );     printf ( "Enter the route of first drivers \n " );     scanf ( " %s " , & d1 . route );     printf ( "Enter the number of kms of first drivers \n " );     scanf ( " %d " , & d1 . kms );     printf ( "Enter the details of drivers no.2 \n " );     printf ( "Enter the name of second drivers \n " );     scanf ( " %s " , & d2 . name );     printf ( "Enter the dlNo of second d...

Storage classes in C.

  #include <stdio.h> // int sum = 897; // int sum = 0; int myfunc ( int a , int b ) {     // int sum;     static int myVar ;     myVar ++;     printf ( "The myVar is %d \n " , myVar );     // sum = a + b;     return myVar ; } //  int myVar = 898; int main () {     int myVar = myfunc ( 3 , 5 );     myVar = myfunc ( 3 , 5 );     myVar = myfunc ( 3 , 5 );     myVar = myfunc ( 3 , 5 );     myVar = myfunc ( 3 , 5 );     myVar = myfunc ( 3 , 5 );         return 0 ; } OUTPUT: The myVar is 1 The myVar is 2 The myVar is 3 The myVar is 4 The myVar is 5 The myVar is 6

How to make calculator in java script.

  <! DOCTYPE html > < html lang = "en" >   < head >     < meta charset = "UTF-8" />     < meta http-equiv = "X-UA-Compatible" content = "IE=edge" />     < meta name = "viewport" content = "width=device-width, initial-scale=1.0" />     < link rel = "stylesheet" href = "style.css" />     < title > Calculator - By Code Traversal </ title >   </ head >   < body >     < div class = "container" >       < div class = "calculator" >         < input type = "text" id = "inputBox" placeholder = "0" />         < div >           < button class = "button operator" > AC </ button >           < button class = "button operator" > DEL </ button >           < butt...