Change Position (Programming for Engineers)
#include<stdio.h>
int main (void)
{
int x, y, z;
scanf("%d", &x);
scanf("%d", &y);
z = x;
x = y;
y = z;
z = (y>x)? y:z;
printf("%d %d", x, y);
system("pause");
return 0;
}
int main (void)
{
int x, y, z;
scanf("%d", &x);
scanf("%d", &y);
z = x;
x = y;
y = z;
z = (y>x)? y:z;
printf("%d %d", x, y);
system("pause");
return 0;
}
Assignment 1 (Programming for Engineers)
Flowchart |
int main ()
{
int x = 0;
printf("\n\t _______________________________________________\n");
printf("\t|\t\t|\t\t|\t\t|");
printf("\n\t|\tNUMBER\t|\tSQUARED\t|\tCUBE\t\|\n");
printf("\t|_______________|_______________|_______________|\n");
while(x <=10)
{
int a, b, c;
printf("\t|\t\t|\t\t|\t\t|");
printf("\n\t|\t%d\t|\t%d\t|\t%d\t|\n", a, b, c);
printf("\t|_______________|_______________|_______________|\n");
x ++;
}
system ("pause");
return 0;
}
Output |
Control Statement
if else
#include<stdio.h>
int main()
{
int grade;
printf( "Enter your mark: " );
scanf("%d", &grade );
if ( grade>= 60 )
printf( "\nPass\n" );
else
printf( "\nFail\n" );
system ( "pause" );
return 0;
}
Output |
conditional operator ( :? )
#include<stdio.h>
int main()
{
int grade;
printf( "Enter your mark: " );
scanf("%d", &grade );
grade >= 60? printf( "Pass\n" ) : printf( "Fail\n" );
system ( "pause" );
return 0;
}
======================================================================
#include<stdio.h>
int main()
{
int grade;
printf( "Enter your mark: " );
scanf("%d", &grade );
printf( "%s", grade>=60? "Pass\n" : "Fail\n");
system ( "pause" );
return 0;
}
Supplication on finishing the ablution
Subscribe to:
Posts (Atom)