IMPORTANT QUESTIONS ON C LANGUAGE FOR PLACEMENT DRIVES #3

Question #1:

#include<stdio.h>

void main()

{

  int const *cp;

  int Res,Num=90;

  cp=&Num;

  Res=++(*cp);

  printf(“%d”,Res);

}

  • 90
  • 91
  • Compiler Error
  • Address of Num

Question #2:

#include<stdio.h>

#define CUBE(x) x*x*x

void main()

{

  int Res;

  Res=8/CUBE(2);

  printf(“%d”,Res);

}

  • 2
  • 4
  • 1
  • 16

Question #3:

#include<stdio.h>

#define CUBE(x) (x*x*x)

void main()

{

int Res;

Res=8/CUBE(1+1);

printf(“%d”,Res);

}

  • 1
  • 2
  • 4
  • 16

Question #4:

#include<stdio.h>

enum colors{Red,Blue,Green};

void main()

{

  printf(“%d %d %d”,Red,Blue,Green);

}

  • 1 2 3
  • 0 1 2
  • Error due to %d
  • R B G

Question #5:

#include<stdio.h>

#define scanf() 121

void main()

{

printf(“%d\n”,scanf());

}

  • Error
  • 121
  • Scanf()
  • 0

 

Important Questions on C Language for Placement Drives #2

Question #1:

#include<stdio.h>

void main()

{

       int m=10,n=5,Res;

       Res=m++ + ++n;

       printf(“%d”,Res);

}

  • 16 11 5
  • 16 11 6
  • 15 11 6
  • 17 11 6

Question #2:

#include<stdio.h>

void main()

{

     extern float Num;

     Num=99.9;

     printf(”%f”,Num);

}

  • Undefined reference to Num
  • 99.9
  • No Output
  • Runtime Error

Question #3:

#include<stdio.h>

void main()

{

float *Ptr

printf(“%d %d”,sizeof(Ptr),sizeof(*Ptr));

}

  • 4 4
  • 8 4
  • 8 8
  • 4 8

Question #4:

#include<stdio.h>

main()

{

printf(“Hello”);

printf(“\bHow”);

printf(“\rFine”);

}

  • HelloHow
  • HelloHowFine
  • FineHow
  • HowFine

Question #5:

main()

{

char *Ptr;

Ptr=“LearnTechToTech”;

printf(“%c\n”,*&*Ptr);

}

  • L
  • T
  • LearnTechToTech
  • Tech

 

Note: To understand the concept Click on the following link:

 

Important Questions on C Language for Placement Drives

Question #1:

#include<stdio.h>

void main()

{

     int a=10,b=90;

     printf(“%d”);

}

  • 90
  • 10
  • Compilation Error
  • Runtime Error

Question #2:

#include<stdio.h>

void mian()

{

     printf(“%d”,printf(“Learn TechToTech”));

}

  • Learn TechToTech
  • 0
  • 1
  • Error

Question #3

#include<stdio.h>

void main()

{

int Num;

printf(“%d”,scanf(“%d”,&Num)); //Suppose input is 23

}

  • 0
  • 1
  • 23
  • Error

Question #4

#include<stdio.h>

void main()

{

int Res;

Res=(8&7) && (8&10);

printf(“%d”,Res);

}

  • 0
  • 1
  • 8
  • 10

Question #5

#include<stdio.h>

void main()

{

int Res;

Res=10<<2;

printf(“%d”,Res);

}

  • 10
  • 40
  • 5
  • 2

 

 

Some important C Programs

//Write a C Program to convert lower case to upper case and vice versa

#include<stdio.h>
void main()
{
char ch;
printf(“Enter the Character:”);
scanf(“%c”,&ch);
if(islower(ch))
printf(“%c”,toupper(ch));
else
printf(“%c”,tolower(ch));

}

//Write a C Program to display the ASCII value with characters

#include<stdio.h>
void main()
{
int Num;
for(Num=0;Num<=255;Num++)
printf(“%d=%c\n”,Num,Num);
}

//Write a program to calculate the factorial of a Numbers

#include<stdio.h>
void main()
{
int fact=1,Num,i;
printf(“Enter the Number:”);
scanf(“%d”,&Num);
for(i=Num;i>1;i–)
fact=fact*i;
printf(“Factorial of %d is %d”,Num,fact);
}

//Write a program to swap a two number without using extra variables

#include<stdio.h>
void main()
{
int a,b;
printf(“\nEnter two numbers:”);
scanf(“%d %d”,&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf(“a=%d,b=%d”,a,b);
}

//Write a program to get the salary and gender as a input and calculate the bonus 7% for male and 10 % for female . In addition to that 5% extra bonus for the employee salary less than 10000

#include<stdio.h>
void main()
{
float salary,bonus=0;
char gen;
printf(“Enter the salary and gender:”);
scanf(“%f %c”,&salary,&gen);
if(gen==’M’ || gen==’m’)
bonus=bonus+salary*0.07;
else
bonus=bonus+salary*0.10;
if(salary<10000)
bonus=bonus+salary*0.05;
salary=salary+bonus;
printf(“Salary=%f, Bonus=%f”,salary,bonus);
}

NIMCET-2018 Alert (NIT MCA Common Entrance Test 2018)

Participating Institute

NITs of following Cities:

1.Allahabad

2.Agartala

3.Bhopal

4.Calicut

5.Durgapur

6.Jamshedpur

7.Raipur

8.Kurushetra

9.Warangal

10.Surathkal

11.Tiruchirappalli

Eligibility Criteria

1.Qualification: B.Sc/B.Tech/BE/B.sc(CS)/B.Sc(IT)/BCA/BIT or minimum 3 years full time with Mathematics/Statistics/equivalent as one of the subject from recognized university.

2.Appearing students of the qualifying exam can also participate.

3.Marks: 6.5 CGPA or 60% marks aggregate in Graduation.

Exam pattern

  • Computer : 10 questions
  • English : 20 questions
  • Mathematics : 50 Questions
  • Reasoning and Analytical : 40 Question

Tentative Important Dates

  • Online Registration Starts from: Feb 2018
  • Last date of Print online app: Mar 2018
  • Admit Card issue and Exam: May 2018
  • Result : June 2018

Connection of MySQL and Python using PyMySql

Connection of MySQL and Python using PyMySql

1. Executing SQL query in Python Using PyMySql:

Execute the SQL query by using the Python Programming Language and pyMysql.
Here I have taken the Book database from the MySQL to display the result.

import pymysql
myConn=pymysql.connect(host=’localhost’,user=’root’,password=’root123′, db=’Db_py’)
print (“Connection Established!”)
sql = “Select B_id, B_Name, Price,Author from Book Where B_id = %s “
try :
            B_cur = myConn.cursor()
            B_cur.execute(sql, ( 3 ) )
            for B in B_cur:
                    print (” ———– “)
                    print(“Row: “, B)
                    print (“Book_No: “, B[0])
                    print (“Book_Name: “, B[1])
                    print (“Price: “, B[2] )
                    print(“Author:”, B[3] )

finally:
             myConn.close()

2. Executing Insert statement in Python Using PyMySql:

Execute the SQL insert statement by using the Python Programming Language and pyMysql. Here I have taken the Book database from the MySQL to display the result. In this program , I am trying to insert the data for the next row and Bood id will be automatically generated.

import pymysql
myConn=pymysql.connect(host=’localhost’,user=’root’,password=’root123′,db=’Db_py’)
print (“myConn Established!”)
try :
             B_cur = myConn.cursor()
             sql = “Select max(B_id) from Book “
             B_cur.execute(sql)
             B_id=0
             R1 = B_cur.fetchone()
             if R1 != None and R1[0] != None:
                         B_id = int(int(R1[0]) + 1)
             B_cur = myConn.cursor()
             sql = “Insert into Book (B_id, B_Name, price,author)  values (%s , %s, %s, %s) “
             print (“Insert Book: “, B_id)
             B_cur.execute(sql, (B_id,’Python’,’789′,’Rakesh’))
             myConn.commit()
finally:
             myConn.close()

3.Executing Update statement in Python Using PyMySql:

Execute the SQL update statement by using the Python Programming Language and pyMysql. Here I have taken the Book database from the MySQL to update the result. In this program , I am trying to update the data by taking input from the user:

import pymysql
myConn=pymysql.connect(host=’localhost’,user=’root’,password=’root123′, db=’Db_py’)
print (“myConn Established!”)
try :
              B_cur = myConn.cursor()
             B_id = int(input(“Enter the Book id:”))
             price= int(input(“Enter the Price:”))
             B_cur = myConn.cursor()
             sql = “Update Book set price = %s where B_id = %s”
             print (“Updated Book: “, B_id)
             B_cur.execute(sql, (price,B_id))
             myConn.commit()
             sql = “Select B_id, B_Name, Price,Author from Book Where B_id = %s “
             B_cur = myConn.cursor()
             B_cur.execute(sql, ( B_id ) )
             r1=B_cur.fetchone()
             print(r1)
finally:
myConn.close()

4. Delete Record from MySQL table by using Python:

import pymysql
myConn=pymysql.connect(host=’localhost’,user=’root’,password=’root123′,db=’Db_py’)
print (“myConn Established!”)
try :
            B_cur = myConn.cursor()
            B_id = int(input(“Enter the Book id:”))
            sql = “Delete from Book where B_id = %s”
            R1 = B_cur.execute(sql, ( B_id ) )
myConn.commit()
print (“Deleted! “, R1, ” rows”)
finally:
             myConn.close()  

Live Session on Python Programming Language By Rakesh Roshan

Live Session on Python Programming Language By Rakesh Roshan. Here you will get the tutorial of Python Programming Language from scratch way . You can also ask questions related to python. In this video, I covered the below topics:

  1. Basics of Python
  2. Variables
  3. Type of Data Types
  4. Numbers
  5. String
  6. List
  7. Tuple
  8. Dictionary

What you Get from my WebSite

What you Get from my WebSite

You can learn programming language, latest technologies, Mobile application development, Hands on problem solving in my website by watching the YouTube videos By clicking on the following Link:

https://www.youtube.com/LearnTechToTech

Subscribe to the YouTube Channel for getting the notification of all my new videos. Also if you have any problem in programming or setup than comment your query and I definitely response you within 24 hours.

Goal of this website(www.learnfromrakesh.com)

I developed all the study material in terms of videos or any thing else by consistent working from last 10 months. Definitely students as well as new faculties get benefited with  this site. Anything you want from my side, than please ask to me. The ultimate goal of my site is to serve the people of technology without spending any money or cost. because I feel very bad when students pay money in today’s world where everything is in Internet. I developed al the material by keeping in mind for the Indian students as well as abroad students.

Support from Audiences(Friends, Students, Faculty , Teachers)

I just want support from my students first, please learn the technology from my website and YouTube Channel. Also suggest your friends, brothers, sisters, family members and teachers for my website http://www.learnfromrakesh.com and YouTube Channel. Also I want to support from my faculty colleagues to suggest your students and suggest me for anything improvements are required for the website and channel.

I am requesting to my teachers from school to colleges , please blessed me for doing hard work for improving the content , so that one day every students of India will be the visitors of my website and channel.

Future Plan of My Site

Already more than 160 videos are available in this site where you can learn the following Programming Language/Technologies:

  • Go Programming Language
  • Python Programming Language
  • Internet of Things
  • C|C++ Programming Language
  • Placement Tips
  • Placement and Interview Questions
  • Gaming Development using GDevelop
  • Unix/Linux
  • KAA Open Source
  • Arduino IDE  and many More

In Future I always upload the latest technologies content related to programming, Databases, Technology, Tech news etc regularly and also I develop the contents on-demand according to the requirement from the students and faculties. There is a Plan to upload at least one videos daily in the YouTube Channel “Learn TechToTech“.

Who can access my Website

Everyone can access my site for enhancing the knowledge on IT technology. Because , Now a days everyone required a knowledge of IT for enjoying the latest equipment from the market whether they are Mobile, Smart TV or Home Appliances.

 

 

 

 

 

C Program for Different Pattern

Question 1:

*
**
***
****
*****

#include<stdio.h>
void main()
{
int i,j,n;
printf(“Enter the Number of lines:”);
scanf(“%d”,&n);
for(i=n;i>=1;i–)
{
for(j=n;j>=i;j–)
printf(“*”);
printf(“\n”);
}
}

Question 2:

*****
****
***
**
*

#include<stdio.h>
void main()
{
int i,j;
for(i=5;i>=1;i–)
{
for(j=i;j>1;j–)
printf(“*”);
printf(“\n”);
}
}

Question 3:

*
*      *
*      *      *
*     *       *     *
*      *      *      *      *
#include<stdio.h>
void main()
{
int i,j;
for(i=5;i>=1;i–)
{
for(j=1;j<=i;j++)
printf(” “);
for(j=5;j>=i;j–)
printf(“* “);
printf(“\n”);
}
}

Question 4:

A
AB
ABC
ABCD
ABCDE

#include<stdio.h>
void main()
{
int i,j;
for(i=65;i<=69;i++)
{
for(j=65;j<=i;j++)
printf(“%c”,j);
printf(“\n”);
}
}

Question 5:

*
***
*****
*******
*********

#include<stdio.h>
void main()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=i;j<5;j++)
printf(” “);
for(j=0;j<(2*i+1);j++)
printf(“*”);
printf(“\n”);
}
}

 

 

 

 

 

Advertisements