Skip to main content

C LANGUAGE

 C-PROGRAMMING IN VSCODE

PROJECT NO.1
#include <stdio.h>
//#include <conio.h> not for linux based systems (old header)
#include <curses.h> /*this is a newer header file for modern linux
based systems which provides similar functionality as <conio.h>*/
void main()
{
int a,b,s=0;
//clrscr();
printf("Enter 2 nos");
scanf("%d%d",&a,&b);
s=a+b;
printf("Sum=%d\n",s);
}
/*
# -> preprocessor
include -> directory/folder/headers
std -> standard
io -> input/output
.h -> extension of headerfile
printf() -> output
scanf() -> input
con -> console
io -> input/output
*/

OUTPUT:----



PROJECT NO.2
#include <stdio.h>
#include <curses.h>
void main()
{
int a;int i=0,b=0,k=0,z=0,s=0;
printf("Enter a no");
scanf("%d",&a);int m=a;
for( ;a>0;a=a/10)
s=s*10+a%10;
for(i=1;i<=m;i++)
{
if(m%i==0)
k++;
}
for(b=1;b<=s;b++)
{
if(s%b==0)
z++;
}
if(k==2&&z==2)
printf("emrip");
else
printf("not");
}

OUTPUT:----



CONVERSION CHAR                              DATA-TYPE
  • %d                                int
  • %f                               float
  • %lf                              double
  • %c                                char
  • %s                               String
  • %ld                               long
  • %b                               boolean

Comments

Popular posts from this blog

LINUX COMMANDS CHEATSHEET (PERSONAL)

  COMMANDS CHEATSHEET 1. sudo apt update && sudo apt full-upgrade -> updates and upgrades the operating system. 2. flatpak update -> updates the flatpak applications. 3. sudo dpkg-reconfigure <package><name> -> reconfigures the package to resolve any dependency problem. 4. sudo dpkg -i <file/packagename.deb> -> install .deb files directly from the Terminal. 5. history -> shows the previously given commands. 6. sudo fc-cache --force -> Found from Archwiki . Force unlocks the font-cache database. 7. sudo fc-cache -fv -> Refreshes the font-cache. Useful after installing some fonts. 8. sudo  add-apt-repository ppa:<ppaname> -> add the ppa into the repository. 9. sudo dpkg --add-architecture i386 -> adds 32-bit libraries to the distribution. 10. sudo apt install <package><name> -> installs the specified package along with the dependencies. 11. git clone <repo url> -> downloads the files from selected...

C-PROGRAMMING PERSONAL CODES

  PERSONAL CODES employee.c #include <stdio.h> //#define String #include <curses.h> #include <string.h> //Find the total salary of an employee given the details hra,da & basic double main() {     double BasicPay;     int empcode;     char empname;     printf("Enter the employee name, employee code and basic pay\n");     scanf("%s", &empname);     scanf("%d", &empcode);     scanf("%lf", &BasicPay);     double hra = 30.0 / 100.0 * BasicPay;     double da = 40 / 100.0 * BasicPay;     double salary = BasicPay + hra + da;     double sa = 0.0;     if (empcode <= 15 && salary <= 15000.0)         sa = 20.0 / 100.0 * salary;     if (sa >= 2500.0)         sa = 2500.0;     if (empcode > 15)         sa = 1000.0;     printf("The total ...

C++ PROGRAMMING

  C++ PROGRAMMING Q)0-structure.cpp #include <iostream> int main() {     return 0; } ===================================================================== Q)abc.cpp // Your First C++ Program #include <iostream> int main() {     std::cout << "Hello World!\n";     return 0; } ==================================================================== Q)s2d.cpp #include <iostream> //io -> input/output, stream -> flow //#include <curses.h> int main() {     int n, d, s = 0, m = 1;     std::cout << "Enter a number\n"; //endl -> new line     std::cin >> n;     int k = n;     if (n >= 10 && n <= 99)     {         while (n > 0)         {             d = n % 10;             s = s + d;             m = m * d;   ...