Skip to content

This GitHub repository, created by Alok Singh for SPI Apprenticeship Program 2023-24 (C language) πŸš€, contains program code, notes, and a README.md file offering program overview and author's progress log. A valuable resource for C programming enthusiasts and SPI Apprenticeship participants! πŸ“šπŸ’»

Notifications You must be signed in to change notification settings

Alok-Sci/SPI-Apprenticeship-2023-24--C-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

75 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SPI Apprenticeship Program 2023-24 (c language)

This is a ReadMe file for SPI Apprenticeship Program 2023-24 (C language)

Programs

Q1. WAP to input two numbers and perform the following operation on them: +, -, /, *, %.

Click here to see the answer!

Q2. WAP to input time in seconds and convert it into minutes and seconds.

Click here to see the answer!

Q3. WAP to enter time in seconds and convert it into hours, minutes, and seconds.

Click here to see the answer!

Q4. WAP to enter days and display output in years, months, and days.

Click here to see the answer!

Q5. WAP to enter days and display output in years, months, weeks, and days.

Click here to see the answer!

Q6. WAP to input age and check if you are eligible for voting or not.

Click here to see the answer!

Q7. WAP to input a number and check if it's even or odd number; use if-else.

Click here to see the answer!

Q8. WAP to input two numbers and check if the number is greater or equal to the other number.

Click here to see the answer!

Q9. WAP to input two numbers and check if a number is greater than the other number or not.

Click here to see the answer!

Q10. WAP to print week days like Sunday, Monday, etc; use if-else.

Click here to see the answer!

Miscellaneous

1. Empty main()

What will happen if we leave the main() function empty and run it? \

Source Code:

main(){

}

Click here to check the output!

2. Getting garbage value instead of expected output :

In the given code, this line will through a garbage value.

Source code:

    #include <stdio.h>

    void main(){
        int num;
        printf("%d is a number");
        scanf("%d", &num);
    }

Click here to check the output

ERROR:
Reason is that this statement is missing a parameter to display the variable value, to replace %d

printf("%d is a number");

FIX:

printf("d is a number", num);

2. Program terminates without taking the character input.

In the given code the program will take two integer input and then is expected to take character input, but something else happens when running this code.

ERROR:
This is some kind of compiler error or C language bug in latest version of C.

int num1, num2;
printf("\nEnter first number: ");
scanf("%d", &num1);

printf("\nEnter second number: ");
scanf("%d", &num2);

//operation choice
char choice;
printf("\n Select the operation to perform: ");
scanf("%c",&choice);

Click here to check the output

FIX:
Taking the character input before any integer input will fix this issue. Just change the position of statements used to take inputs.

//operation choice
char choice;
printf("\n Select the operation to perform: ");
scanf("%c",&choice);

int num1, num2;
printf("\nEnter first number: ");
scanf("%d", &num1);

printf("\nEnter second number: ");
scanf("%d", &num2);

About

This GitHub repository, created by Alok Singh for SPI Apprenticeship Program 2023-24 (C language) πŸš€, contains program code, notes, and a README.md file offering program overview and author's progress log. A valuable resource for C programming enthusiasts and SPI Apprenticeship participants! πŸ“šπŸ’»

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages