Skip to content

Instantly share code, notes, and snippets.

View jagdish4501's full-sized avatar
🎯
Focusing on

Jagdish Kumar Patel jagdish4501

🎯
Focusing on
View GitHub Profile
@jagdish4501
jagdish4501 / CH-3 [B] (g).c
Last active April 9, 2023 12:43
Write a program to enter the numbers till the user wants and at the end it should display the count of positive, negative and zeros entered.
#include <stdio.h>
int main()
{
int i, p = 0, n = 0, o = 0, a;
// p--> positive , n---> negative ,o---> zero ;
int wish; // y=1(yess) , n=0(no)
for (i = 1; i >= 1; i++)
{
printf("enter your wish to enter a number or not(y=1,n=0) =");
scanf("%d", &wish);
@jagdish4501
jagdish4501 / CH-3 [B] (f).c
Last active March 30, 2021 07:05
Write a program for a matchstick game being played between the computer and a user. Your program should ensure that the computer always wins. Rules for the game are as follows: 1− There are 21 matchsticks. − The computer asks the player to pick 1, 2, 3, or 4 matchsticks. − After the person picks, the computer does its picking. − Whoever is force…
#include <stdio.h>
int main()
{
int match_stick = 21, user_choice, computer_choice;
printf("total number of match stick=%d\n", match_stick);
while (match_stick >= 1)
{
printf("enter your chioce (1, 2,3 or 4)=");
scanf("%d",& user_choice);
if (user_choice > 4)
@jagdish4501
jagdish4501 / CH-3 [B] (a).c
Created March 30, 2021 07:10
Write a program to calculate overtime pay of 10 employees. Overtime is paid at the rate of Rs. 12.00 per hour for every hour worked above 40 hours. Assume that employees do not work for fractional part of an hour.
#include <stdio.h>
int main()
{
int p, nohw, how, owm;
//nohw=no of hour worked , how=hour over worked
//owm= over time worked money
for (p = 1; p <= 10; p++)
{
printf("enter you hour worked=");
scanf("%d", &nohw);
@jagdish4501
jagdish4501 / CH-3 [B] (b).c
Created March 30, 2021 07:12
Write a program to find the factorial value of any number entered through the keyboard.
#include <stdio.h>
int main()
{
int a, num, facto = 1;
printf("please type any number=");
scanf("%d", &num);
for (a = 1; a <= num; a++)
{
facto = facto * a;
}
@jagdish4501
jagdish4501 / CH-3 [B] (c).c
Created March 30, 2021 07:24
Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another.
#include <stdio.h>
int main()
{
int a, b, c, pow = 1;
printf("enter the value of a, b");
scanf("%d%d", &a, &b);
for (c = 1; c <= b; c++)
{
pow = pow * a;
@jagdish4501
jagdish4501 / CH-3 [B] (d).c
Created March 30, 2021 07:39
Write a program to print all the ASCII values and their equivalent characters using a while loop. The ASCII values vary from 0 to 255.
#include <stdio.h>
int main()
{
int a = 0;
while (a <= 225)
{
printf("ASCII value of %d is=%c\n", a, a);
a++;
@jagdish4501
jagdish4501 / CH-3 [B] (e).c
Created March 30, 2021 09:07
Write a program to print out all Armstrong numbers between 1 and 500. If sum of cubes of each digit of the number is equal to the number itself, then the number is called an Armstrong number. For example, 153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3 * 3 * 3 )
//𝙢𝙚𝙩𝙝𝙤𝙙 1
#include <stdio.h>
#include<math.h>
int main()
{
int num, d1, d2, d3, sum, num2;
//d1 d2 d2 is first,second ,third digit of num
// eg num=34 then d1=0 d2=3 ,d3=4
for (num = 1; num <= 500; num++)
@jagdish4501
jagdish4501 / CH-2 [C] (d).c
Created April 1, 2021 18:38
According to the Gregorian calendar, it was Monday on the date 01/01/1900. If any year is input through the keyboard write a program to find out what is the day on 1st January of this year.
#include <stdio.h>
int main()
{
int curentYear, baseYear, leapYear, no_leapYear, totalNo_ofDay, year, di;
printf("enter current year=");
scanf("%d", &curentYear);
baseYear = 1900;
year = (curentYear - 1) - baseYear;
leapYear = (year / 4); //because 1900 is not leap year
@jagdish4501
jagdish4501 / CH-2 [F] (a).c
Created April 1, 2021 19:26
Any year is entered through the keyboard, write a program to determine whether the year is leap or not.
#include <stdio.h>
int main()
{
int year;
printf("Enter year :");
scanf("%d", &year);
if ((year % 4) == 0)
{
if ((year % 100) == 0)
{
@jagdish4501
jagdish4501 / CH-2 [F] (b).c
Last active April 1, 2021 19:57
Any character is entered through the keyboard, write a program to determine whether the character entered is a capital letter, a small case letter, a digit or a special symbol. The following table shows the range of ASCII values for various characters.
#include <stdio.h>
int main()
{
char ch;
int ASCII;
printf("enter a charcter :");
scanf("%c", &ch);
ASCII = ch;
if (ASCII >= 65 && ASCII <= 90)