This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
//Program to read an array of length 5, change the first element by the last, the second element by the fifth | |
int i, j, a[10], b[10]; | |
printf("Enter 5 numbers: \n"); | |
for (i = 0; i < 5; i++) | |
{ | |
scanf("%d ", &a[i]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
//Program to find and print the square of each one of the even values from 1 to a specified value | |
int x, i; | |
printf("Input an integer: "); | |
scanf("%d", &x); | |
printf("List of square of each one of the even values from 1 to %d : \n", x); | |
for(i = 2; i <= x; i++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
//Program that reads 5 numbers and counts the number of positive and negative numbers | |
int n[5]; | |
int i,pos = 0,neg = 0; | |
for(i = 0; i < 5; i++) | |
{ | |
printf("Input the elements n[%d] : ", i); | |
scanf("%d", &n[i]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
//Program that prints all even numbers between 1 and 50 | |
int i; | |
printf("The even numbers between 1 to 50 are: \n"); | |
for(i = 1; i <= 50; i++) | |
{ | |
if(i % 2 == 0) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
//Program that reads an integer between 1 and 12 and prints the month of the year | |
int month; | |
printf("Input a number between 1 - 12:"); | |
scanf("%d", &month); | |
switch(month) | |
{ | |
case 1: printf("January\n");break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
//Program to read an integer from the keyboard and check the specified range where it belongs | |
int x; | |
printf("Input an integer: "); | |
scanf("%d", &x); | |
if(x >= 0 && x <= 20) | |
{ | |
printf("Range [0, 20]"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<math.h> | |
int main() | |
{ | |
//Program to print the roots of numbers using Bhaskara's formula | |
double a, b, c, temp; | |
printf("Input the first number: "); | |
scanf("%lf", &a); | |
printf("Input the second number: "); | |
scanf("%lf", &b); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
int p, q, r, s; | |
printf("Input the first integer: "); | |
scanf("%d", &p); | |
printf("Input the second integer: "); | |
scanf("%d", &q); | |
printf("Input the third integer: "); | |
scanf("%d", &r); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
//Program to convert integer into years, months and days | |
int days, months, years; | |
printf("Input days: "); | |
scanf("%d", &days); | |
years = days / 365; | |
months = (days % 365) / 30; | |
days = (days % 365) % 30; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
//Program to convert integer to hours, minutes and seconds | |
int hrs, min, sec; | |
printf("Input seconds: "); | |
scanf("%d", &sec); | |
hrs = sec / 3600; | |
min = (sec % 3600) / 60; | |
sec = (sec % 3600) % 60; |
NewerOlder